<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.sql.DataSource" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.sql.*" %>
<%--
  Created by IntelliJ IDEA.
  User: yqx
  Date: 2022/7/2
  Time: 16:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"  %>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="酒店预定">
    <title>Home</title>
    <!-- core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/styles.css" rel="stylesheet">

    <style>
        .fl_left{
            float: left;
        }
        .fl_right{
            float: right;
        }
        .page-center{
            text-align: center;
        }

    </style>
</head>
<%
    Connection con=null;
    Statement sql;
    ResultSet rs;
    ArrayList<String>hotelAddress=new ArrayList<>();
    ArrayList<String>hotelName=new ArrayList<>();
    ArrayList<String> hotelID= new ArrayList<>();
//    Context context=new InitialContext();
//    Context contextNeeded =(Context) context.lookup("java:comp/env");
//    DataSource ds=(DataSource) contextNeeded.lookup("hotelConn");
    String driver="org.mariadb.jdbc.Driver";
    String url="jdbc:mariadb://localhost:3306/hotel-management-system";
    try {
        Class.forName(driver);
        con= DriverManager.getConnection(url,"root","123456");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    try {
//        con=ds.getConnection();
        assert con != null;
        sql=con.createStatement();
        //读取酒店详情表
        String ex="select * from hotels";
        rs=sql.executeQuery(ex);
        while (rs.next()){
            hotelAddress.add(rs.getString("HotelAddress"));
            hotelName.add(rs.getString("HotelName"));
            hotelID.add(rs.getString("HotelID"));
        }
    }catch (SQLException e){
        System.out.print(e);
    }
    finally {
        try {
            assert con != null;
            con.close();
        }catch (Exception e){
            System.out.print(e);
        }
    }

%>

<body id="home">
<header id="header">
    <nav id="main-nav" class="navbar navbar-default navbar-fixed-top" >
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" ><img src="image/图标.png" alt="logo"></a>
            </div>

                <form action="Servlet" class=" navbar-left" >
                    <div class="page-center">
<%--                    <div class="center-block">--%>
                    <span class="fl_left"><input type="text"  name="search" class="form-control " placeholder="请输入目的地"></span>
<%--            </div>--%>

<%--                    <div class="center-block">--%>
                    <span class="fl_right"><button type="submit"  class="btn btn-default">搜索</button>></span>

            </div>
                </form>
<%--                <span class=""><a href="Servlet"><span>搜索</span></a> </span>--%>


            <div class="collapse navbar-collapse navbar-right">
                <ul class="nav navbar-nav">
                    <li class="scroll active"><a href="login.jsp">登录</a></li>
                    <li class="scroll"><a href="register.jsp">注册</a></li>
                    <li class="scroll"><a href="person.jsp">个人空间</a></li>
<%--                    <li class="scroll"><a href="#">联系客服</a></li>--%>

                </ul>
            </div>
        </div>
    </nav>
</header>

<section class="demo-2">
    <div id="slider" class="sl-slider-wrapper">
        <div class="sl-slider">
            <div class="sl-slide-inner">
                <img src="image/banner/1.jpg" alt="">
                </div>
        </div>
    </div>

</section>

<section id="services" >
    <div class="container">
        <div class="section-header">
            <h2 class="section-title">世界这么大，总要去看看</h2>
            <p>一流的酒店，一流的服务，一流的收费</p>
        </div>

        <div class="row">
            <div class="features">
                <div class="col-md-4 col-sm-6">
                    <div class="media service-box">
                        <div class="media-body">
                            <h4 class="media-heading">精选酒店</h4>
                            <p>精选各地酒店，只为您旅途愉快</p>
                        </div>
                    </div>
                </div>
                
                <div class="col-md-4 col-sm-6">
                    <div class="media service-box">
                        <div class="media-body">
                            <h4 class="media-heading">优质服务</h4>
                            <p>提供一流的酒店服务，只为旅途乘兴有归</p>
                        </div>
                    </div>
                </div>

                <div class="col-md-4 col-sm-6">
                    <div class="media service-box">
                        <div class="media-body">
                            <h4 class="media-heading">最优折扣</h4>
                            <p>以最低的价格，守护您的旅途</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>



<section id="portfolio">
    <div class="container">
        <div class="section-header">
            <h2 >酒店推荐</h2>
        </div>

        <div class="portfolio-items">
            <div class="portfolio-item">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/01.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(0));%>&hotelAddress=<%out.print(hotelAddress.get(0));%>&hotelID=<%out.print(hotelID.get(0));%>&from=index"><%out.print(hotelName.get(0));%></a></h4>
                    <p><%out.print(hotelAddress.get(0));%></p>
                </div>
            </div>

            <div class="portfolio-item mobile development">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/02.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(1));%>&hotelAddress=<%out.print(hotelAddress.get(1));%>&hotelID=<%out.print(hotelID.get(1));%>&from=index"><%out.print(hotelName.get(1));%></a></h4>
                    <p><%out.print(hotelAddress.get(1));%></p>

                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item designing">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/03.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(2));%>&hotelAddress=<%out.print(hotelAddress.get(2));%>&hotelID=<%out.print(hotelID.get(2));%>&from=index"><%out.print(hotelName.get(2));%></a></h4>
                    <p><%out.print(hotelAddress.get(2));%></p>

                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item mobile">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/04.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(3));%>&hotelAddress=<%out.print(hotelAddress.get(3));%>&hotelID=<%out.print(hotelID.get(3));%>&from=index"><%out.print(hotelName.get(3));%></a></h4>
                    <p><%out.print(hotelAddress.get(3));%></p>

                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item designing development">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/05.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(4));%>&hotelAddress=<%out.print(hotelAddress.get(4));%>&hotelID=<%out.print(hotelID.get(4));%>&from=index"><%out.print(hotelName.get(4));%></a></h4>
                    <p><%out.print(hotelAddress.get(4));%></p>

                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item mobile">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/06.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(5));%>&hotelAddress=<%out.print(hotelAddress.get(5));%>&hotelID=<%out.print(hotelID.get(5));%>&from=index"><%out.print(hotelName.get(5));%></a></h4>
                    <p><%out.print(hotelAddress.get(5));%></p>

                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item designing development">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/07.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(6));%>&hotelAddress=<%out.print(hotelAddress.get(6));%>&hotelID=<%out.print(hotelID.get(6));%>&from=index"><%out.print(hotelName.get(6));%></a></h4>
                    <p><%out.print(hotelAddress.get(6));%></p>
                </div>
            </div><!--/.portfolio-item-->

            <div class="portfolio-item mobile">
                <div class="portfolio-item-inner">
                    <img class="img-responsive" src="image/portfolio/08.jpg" alt="">
                    <h4 class="media-heading"><a href="QueryServlet?hotelName=<%out.print(hotelName.get(7));%>&hotelAddress=<%out.print(hotelAddress.get(7));%>&hotelID=<%out.print(hotelID.get(7));%>&from=index"><%out.print(hotelName.get(7));%></a></h4>
                    <p><%out.print(hotelAddress.get(7));%></p>
                </div>
            </div><!--/.portfolio-item-->
        </div>
    </div><!--/.container-->
</section><!--/#portfolio-->




<footer id="footer">
    <div class="container">
        <div class="row">
            <div class="col-sm-6">7月小学期
            </div>
        </div>
    </div>
</footer><!--/#footer-->

</body>
</html>
